package com.project_test.kun.travelling_1st.HomePage.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.project_test.kun.travelling_1st.R;
import com.squareup.picasso.Picasso;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 16-10-19.
 */
public class HomePDetilAdapter extends BaseAdapter {
    private Context mContext;
    private List<Map<String,Object>> data;
    private ViewHolder mHolder;

    public HomePDetilAdapter(Context context, List<Map<String, Object>> data) {
        mContext = context;
        this.data = data;
    }

    @Override
    public int getCount() {
        return data!=null?data.size():0;
    }

    @Override
    public Map<String,Object> getItem(int i) {
        return data.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
       if (view==null){
           view= LayoutInflater.from(mContext).inflate(R.layout.item_activity_homep_detil,viewGroup,false);
           mHolder = new ViewHolder();
            mHolder.mImageView= (ImageView) view.findViewById(R.id.item_image_activity_hp_detil);
           view.setTag(mHolder);
       }else{
           mHolder= (ViewHolder) view.getTag();
       }
        //控件赋值
        Map<String, Object> map = data.get(i);
        Picasso.with(mContext).load((String)map.get("pic")).into(mHolder.mImageView);

        return view;
    }
    class ViewHolder{
       private  ImageView mImageView;
    }
}
